package com.neusoft.mapper;

import java.util.List;

import org.apache.ibatis.annotations.*;

import com.neusoft.po.Orders;

@Mapper
public interface OrdersMapper {

	@Insert("insert into orders(userId,businessId,orderDate,orderTotal,daId,orderState,points,coupon) values(#{userId},#{businessId},#{orderDate},#{orderTotal},#{daId},0,#{points},#{coupon})")
	@Options(useGeneratedKeys=true,keyProperty = "orderId",keyColumn = "orderId")
	public int saveOrders(Orders orders);
	
	public Orders getOrdersById(Integer orderId);
	public List<Orders>listOrdersByUserId(String userId);
	
	@Update("update orders set orderState=1 where orderId =#{orderId}")
	public int updateOrderState(Integer orderId);

	@Update("update orders set orderState=1 where orderId=#{orderId}")
	public int finishOrders(Orders orders);

	@Delete("delete from orders where orderId=#{orderId}")
	public int deleteOrders(Orders orders);

	@Delete("delete from orders where userId=#{userId}")
	public int deleteOrdersById(String userId);
	
//	@Select("select scoreRecord from orders where userId=#{userId} and orderId =#{orderId}")
//	public int getRecordByUserIdByOrderId(String userId,Integer orderId);
}
